package cn.broadmax.boot.modules.jzm.controller;


import cn.broadmax.boot.base.SuperController;
import cn.broadmax.boot.base.message.SResult;
import cn.broadmax.boot.modules.jzm.bean.JzFileTypeSearch;
import cn.broadmax.boot.modules.jzm.entity.JzFileType;
import cn.broadmax.boot.modules.jzm.mapper.JzFileTypeMapper;
import cn.broadmax.boot.modules.jzm.service.IJzFileTypeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jexx.util.Console;
import lombok.RequiredArgsConstructor;
import net.sf.saxon.functions.ConstantFunction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 案卷类型 前端控制器
 * </p>
 *
 * @author jexx
 * @since 2021-05-22
 */
@Api(tags = "案卷类型")
@RestController
@RequestMapping("/jzm/jzFileType")
@RequiredArgsConstructor
public class JzFileTypeController  extends SuperController {

    @Autowired
    private final IJzFileTypeService iJzFileTypeService;

    @Autowired
    private JzFileTypeMapper jzFileTypeMapper;

    @ApiOperation("分页查询案卷类型")
    @GetMapping(value = "")
    public SResult<IPage<JzFileType>> pageTypes(){
        QueryWrapper<JzFileType> wrapper = new QueryWrapper<>();
        IPage<JzFileType> page = iJzFileTypeService.page(getPage(), wrapper);
        return SResult.ok("", page);
    }

    @ApiOperation("案卷备注修改")
    @PutMapping(value = "/update/{id}")
    public SResult<Boolean> updatePage(@PathVariable Integer id, @RequestBody JzFileType jzFileType){
        jzFileType.setId(id);
        iJzFileTypeService.updateById(jzFileType);
        return SResult.ok("", Boolean.TRUE);
    }

    @ApiOperation("添加")
    @PutMapping(value = "/insert")
    public SResult<Boolean> InsertPage(@RequestBody JzFileType jzFileType){
        jzFileTypeMapper.insert(jzFileType);
        return SResult.ok("", Boolean.TRUE);
    }

    @ApiOperation("删除")
    @DeleteMapping(value = "/delete/{id}")
    public SResult<Boolean> DeletePage(@PathVariable String id){
        iJzFileTypeService.removeById(id);
        return SResult.ok("", Boolean.TRUE);
    }

}
